package inventory.daoImplementer;

import java.sql.SQLException;

import dbhandelling.Crude;
import inventory.model.CategoryMaster;
import inventory.daoInterface.CategoryMasterDao;

public class CategoryMasterImplementor extends Crude implements CategoryMasterDao
{
	
	@Override
	public void add(CategoryMaster category) throws Exception 
	{
		insert(category);
	}

	@Override
	public void update(CategoryMaster category) throws Exception 
	{
		super.update("CategoryMaster","status" ,category.getStatus()+"", "catCode",category.getCatCode()+"");
	}

	@Override
	public void delete(CategoryMaster category) throws Exception 
	{
		super.delete("CategoryMaster","categoryNo",category.getCatCode()+"");
	}

	@Override
	public CategoryMaster retreive(String conditionField, String ConditionValue) throws Exception 
	{
		CategoryMaster category=(CategoryMaster) super.retreive("CategoryMaster",conditionField, ConditionValue);
		return category;
	}

	@Override
	public CategoryMaster[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		CategoryMaster[] categorys;
		Object[] obj=super.retreiveArrayOnCondition("CategoryMaster", conditionField, conditionValue);
		categorys=new CategoryMaster[obj.length];
		
		for(int i=0;i<categorys.length;i++)
		{
			categorys[i]=(CategoryMaster) obj[i];
		}
		
		return categorys;
	}

	@Override
	public CategoryMaster[] retreiveAll() throws Exception 
	{
		CategoryMaster[] categorys;
		
		Object[] obj=super.retreiveAll("CategoryMaster");
		
		categorys=new CategoryMaster[obj.length];
		
		for(int i=0;i<categorys.length;i++)
		{
			categorys[i]=(CategoryMaster) obj[i];
		}
		
		return categorys;
	}

}
